home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Extravaganza - Disc 4
/
Shareware Extravaganza - Over 25,000 Programs (The Ultimate Shareware Company)(Disc 4 of 4)(1993).iso
/
cad
/
autolb.zip
/
AUTOLB.LSP
Wrap
Text File
|
1990-01-14
|
6KB
|
176 lines
;AUTOLBRK.LSP
;***************************************************************
;File: AUTOLBRK.LSP Copyright (C) Dan Hamilton 1988
;
;Function to automatically, without user interaction, search a drawing for any
;block(s) (in a list), on all lines, and measure the width of the block at the
;points of intersection with the line and then break the line. This will work at
;any Zoom size (viewsize).
;Developed for a particular application involving a lighting designers use of
;lighting instruments on pipes, this function can easily be adapted to any blocks
;on any lines.
;
;The idea for this was inspired by BREAKL.LSP by Eliot Shanabrook and John
;Intorcio. BREAKL works terrific, but often lights are
;moved around during creation of the drawing, and I was asked to help find a way
;to break the intrument-intersecting lines automatically when the drawing was
;completed.
;
;I would be glad to hear any suggestions as how to improve the code on this
;function, I know it works but I'm sure it could be better as this is my first
;Autolisp program.
;
;Follow some random notes on the program:
;
;It's big. (vmon) is included to save memory.
;
;(LList) is the list of block names, in this case lighting instr.
;
;(the number 0.003249 used with the VIEWSIZE variable to adjust
;the breakpoints was found by dividing the STEP1 variable amount by the current
;viewsize when I first solved the problem.
;
;The SETTINGS in use were Architect. Using AUTOCAD VER. 9.
;
;Enjoy....
;*************************************************************************
;CREATE THE WINDOW FROM THE LINE ENDS
;
(VMON)
(DEFUN MAKW()
(setq *lines* (+ *lines* 1))
(setq pt10 (cdr (assoc 10 eas))); SET THE POINTS TO THE
(setq pt11 (cdr (assoc 11 eas))); ENDS OF THE LINE
(SETQ AN1 (ANGLE PT10 PT11))
;
; AND CREATE THE SELECTION SET
;
(SETQ SSET (SSGET "C" pt10 pt11))
(setq pt10 nil)
(setq pt11 nil)
(setq count 0)
(if sset (loop)) ; If we got anything....
) ; END FUNCTION MAKW
;
;NOW CHECK THE SET FOR LIGHT INSTRUMENTS
;
(DEFUN LOOP()
(while (>=(SSLENGTH SSET) (+ COUNT 1))
(SETQ INSTR(CDR(ASSOC 2(ENTGET(SSNAME SSET COUNT)))))
;
(IF (OR (MEMBER INSTR LLIST) (/= INSTR NIL))
(FILT) ; check for LIGHTS
(PROGN
(SETQ COUNT (1+ COUNT))
(SETQ INSTR NIL)
(LOOP)
) ; END PROGN
) ; END IF
(SETQ COUNT (+ COUNT 1))
) ; end WHILE
) ; END FUNCTION LOOP
;
(DEFUN FILT()
(setq *lights* (+ *lights* 1))
(SETQ PTI (CDR (ASSOC 10 (ENTGET (SSNAME SSET COUNT)))))
(princ (strcat "\nCurrently processing pipe # "(rtos (float
*lines*) 2 0)",Instrument # "(rtos (float *lights*) 2 0) " labeled "instr))
;
;the insertion point of the block (pti) is on the line(eas)
;
(setq step 0.5) ; initialize the step size
(searchr) ; go right
(setq step 0.5) ; reset
(setq an2 (+ AN1 (DTR 180))) ; flip the angle 180 **DTR NOT DEFINED HERE**
(searchl) ; and go left **INCLUDED IN ACAD.LSP**
(command "break" ptl ptr)
(setq step nil)
(setq step1 nil)
(setq newptr nil)
(setq ptr nil)
(setq newptl nil)
(setq ptl nil)
(setq COUNT (1+ COUNT))
(LOOP)
) ; END FUNTION FILT
;
(DEFUN SEARCHR()
(setq newptr (polar pti an1 step)) ; new point to the right of pti
(if (NULL (osnap newptr "ins")); find the block
(progn ; if nothing there, try again
(setq step(+ step 0.3))
(searchr)
); end progn
); end if
(setq step1 0.1)
(while (and (osnap newptr "ins")) ; if still the block,keep looking
(setq newptr (polar pti an1 (+ step step1)))
(setq step1 (+ step1 0.1))
) ; end while
(setq step1 (+ step1 (* 0.003249 (getvar "viewsize"))))
; adjust the step needed to get past the block's line thickness
; on any given viewsize
;
(setq ptr (POLAR PTI AN1 (+ STEP STEP1))) ; SET BREAK POINT
) ; end function searchr
;
;
(DEFUN SEARCHL()
(setq newptl (polar pti an2 step)) ; new point to the left of newpti
(if (NULL (osnap newptl "ins"))
(progn ; if nothing there, try again
(setq step(+ step 0.3))
(searchl)
); end progn
); end if
(setq step1 0.1)
(while (and (osnap newptl "ins"))
(setq newptl (polar pti an2 (+ step step1)))
(setq step1 (+ step1 0.1))
) ; end while
(setq step1 (+ step1 (* 0.003249 (getvar "viewsize"))))
(SETQ PTL (POLAR PTI AN2 (+ STEP STEP1)))
) ; end function searchl
;
;
(DEFUN C:BREAKL()
(setvar "CMDECHO" 0)
(COMMAND "SNAP" OFF)
(VMON)
(SETQ PICSIZ(GETVAR "PICKBOX"))
(SETVAR "PICKBOX" 1)
(setq vz(getvar "viewsize"))
(setq apsave (getvar "aperture"))
(command "aperture" 1)
(terpri)
(SETQ LLIST (list "LEKO4" "LEKO4B" "LEKO9" "LEKO9B" "LEKO10"
"LEKO12" "LEKO12B" "LEKO16" "LEKO16B" "LEKO22" "LEKO22B" "FR6"
"FR6B" "FR8" "FR8B" "FR10" "FR10B" "FR14" "FR14B"))
(setq *lines* 0)
(setq *lights* 0)
;
(setq e(entnext))
;
(while e
(setq eas (entget e))
(setq en (CDR (ASSOC 0 EAS)))
(if (= en "LINE")
(progn
(MAKW)
(SETQ E (ENTNEXT E))
) ; END PROGN
(SETQ E (ENTNEXT E))
) ; END IF
) ; end while
(redraw)
(princ (strcat "\nProcessed "(rtos (float *lines*) 2 0) "Pipes
and "(rtos (float *lights*) 2 0)" instruments."))
(SETQ LLIST NIL)
(SETVAR "APERTURE" APSAVE)
(SETVAR "PICKBOX" PICSIZ)
(terpri)
) ; END FUNCTION BREAKL
;
;